-
-
Notifications
You must be signed in to change notification settings - Fork 30
core: Fix thread section alignment. #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
core: Fix thread section alignment. #209
Conversation
6588cbd
to
ccc56ce
Compare
8bdc53e
to
1bab673
Compare
The _static_thread_data struct contains int64_t members that require 8-byte alignment. When placed in a 4-byte aligned section, it causes the linker to insert padding, which in turn causes __static_thread_data_list_start to point to the padding not to the first iterable. GNU ld automatically aligns output sections based on the strictest alignment requirement of input sections, so moving __static_thread_data_list to its own section fixes the problem. Signed-off-by: iabdalkader <[email protected]>
According to Zephyr documentation, k_thread_create() both initializes and starts the thread. The second loop that was calling k_thread_start() on each static thread was redundant. Signed-off-by: iabdalkader <[email protected]>
1bab673
to
9416d15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. With the following change, this PR will also fix the Region ... overlaps with ...
issue AFAICS.
|
||
.static_thread_data_area : { | ||
__static_thread_data_list_start = .; | ||
KEEP(*(SORT_BY_NAME(.__static_thread_data.static.*))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KEEP(*(SORT_BY_NAME(.__static_thread_data.static.*))); | |
KEEP(*(.static_thread_data_area SORT_BY_NAME(.__static_thread_data.*))); |
|
||
.static_thread_data_area : { | ||
__static_thread_data_list_start = .; | ||
KEEP(*(SORT_BY_NAME(.__static_thread_data.static.*))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KEEP(*(SORT_BY_NAME(.__static_thread_data.static.*))); | |
KEEP(*(.static_thread_data_area SORT_BY_NAME(.__static_thread_data.*))); |
The _static_thread_data struct contains int64_t members that require 8-byte alignment. When placed in a 4-byte aligned section, it causes the linker to insert padding, which in turn causes
__static_thread_data_list_start
to point to the padding not to the first iterable.GNU ld automatically aligns output sections based on the strictest alignment requirement of input sections, so moving
__static_thread_data_list
to its own section fixes the problem.